#include "./ServerEventsDispatcher.h"
#include "../Commands/LaunchEvent.h"
#include "./Objects/GameObject.h"
#include "../Commands/Queue.h"
#include "../Network/ConnectionPool.h"

using namespace GameLogic;

// @networking Przepychanie komend odpowiadajacych za zdarzenia obiektow

void ServerEventsDispatcher::dispatchOnHitImpassableTile( Objects::GameObject* subject ) {
	Commands::Command* cmd = new Commands::LaunchEvent(
			Commands::LaunchEvent::onHitImpassableTile,
			subject
	);
	Commands::Queue::getInstance().push( cmd );
	Network::ConnectionPool::getInstance().broadcast( cmd );
}

void ServerEventsDispatcher::dispatchOnHit( Objects::GameObject* obj1, Objects::GameObject* obj2 ) {
	Commands::Command* cmd = new Commands::LaunchEvent(
			Commands::LaunchEvent::onHit,
			obj1, obj2
	);
	Commands::Queue::getInstance().push( cmd );
	//TODO: tworzy komende onHit <done>
	//		wstawia ja do lokalnej kolejki komend <done>
	//		rozsyla ja do klientow
}
